#!/usr/bin/env bash

awk '
{
    split($5, arr, "=");
    ind=int(arr[2]);
    split($7, arr, "=");
    val=arr[2];
    ping[ind]=val;
}
END {
    maxind=ind;
    for(i=0; i<=maxind; ++i)
    {
        if(i in ping)
        {
        }
        else
        {
            ping[i]=1000;
        }
        printf("%d %s\n", i, ping[i]) >resultfile;
        if(i % 5 == 0)
        {
            printf("%d %s\n", i, ping[i]) >pickfile;
        }
    }
}
' resultfile=$2 pickfile=$3 $1
